home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9941 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.0 KB  |  73 lines

  1. Newsgroups: comp.lang.c++
  2. Path: news.ner.bbnplanet.net!daprez!panther!otisg
  3. From: otisg@panther.middlebury.edu (Otis Gospodnetic)
  4. Subject: Process Scheduling (Mult. Feedback Queues) question
  5. Message-ID: <357cc$12f26.1a1@daprez>
  6. Date: Tue, 05 Mar 1996 06:47:37 GMT
  7. X-Newsreader: TIN [version 1.2 PL2]
  8.  
  9.  
  10. Hello, 
  11.  
  12. a friend and I need some help with our Process Scheduling simulation, that
  13. we are trying to implement in C++....fun....
  14. We need to simulate multiple feedback queues.
  15. So, we said, we'll make each process (hereafter called a job) a struct, that
  16. will have some data and a pointer to the next struct of the same kind....
  17. So we did something like this:
  18.  
  19. typedef struct JobStruct {
  20.         // a bunch of struct members here, the data stuff
  21.     struct JobStruct *next; // Pointer to the next Job in the Queue
  22.   } Job;
  23.  
  24.  
  25. that looks okay so far, right ?
  26. then since we need to have multiple queues we decided that queues should have
  27. some data (like quantum, priority/level) and then a pointer to the next queue
  28. level (1->2->3....) and a pointer to the first Job in that queue.
  29. So we tried declaring it as follows (again some struct):
  30.  
  31. typedef struct QueueStruct {
  32.   int Quantum;              // Quantum for Level
  33.   int Level;                // Priority
  34.  
  35. // Now I am really not sure we declared this pointer to the first job in the
  36. // queue right here... comments ?
  37.   Job *JobStruct;           // Ptr to the First Job in Queue
  38.   struct QueueStruct *next; // Ptr to the Next Queue
  39.   } Queue;
  40.  
  41. that pointer to a Job struct looks weird to me....
  42. what should it be, if the above is incorrect ?  Gotta love those pointers....
  43.  
  44. Also, would some different ADTs b better for doing this ?
  45. A Stack for Queues instead of a struct with pointers  ?
  46.  
  47. Thanks !
  48.  
  49. Otis
  50. P.S.
  51. this is how we "imagine" the whole thing:
  52.  
  53. Q1 -> J1 -> J2 -> J3 -> ..... -> NULL
  54. |
  55. V
  56. Q2 -> J1 -> J2 -> J3 -> ..... -> NULL
  57. |
  58. V
  59. Q3 -> J1 -> J2 -> J3 -> ..... -> NULL
  60. |
  61. V
  62. .
  63. .
  64. |
  65. V
  66. NULL
  67.  
  68. -- 
  69. Otis.Gospodnetic@mail.middlebury.edu
  70. Information Technology Services
  71. Middlebury College
  72.  
  73.